package com.karst.essentials.chapter07
{
	import com.karst.essentials.chapter07.galaxyExample.GalaxyExample;
	
	import flash.display.Sprite;
	
	public class Chapter07View extends Sprite
	{
		public static const SECTION_LIST : Array = 
			["颜色 FlatShadeMaterial&位图ShadedMaterial", "Gouraud Shading 高洛德着色渲染法",
			"Cell Shader 赛璐珞着色法", "Phongshading冯氏平滑质感着色器",
			"Bumping your materials 凹凸化材质", "Reflection mapping 反射贴图",
			"例子——shading the Earth in our galaxy"
			 ] ;
		
		public function Chapter07View()
		{
			super();
		}
		
		
		public function showSection( $section : String = "" ) : void
		{
			while( numChildren )
				removeChildAt( 0 ) ;
			switch( $section )
			{
				case SECTION_LIST[0] :
					createFlatShadingExample() ;
					break ;
				case SECTION_LIST[1] :
					createGourandExample() ;
					break ;
				case SECTION_LIST[2] :
					createCellShaderExample() ;
					break ;
				case SECTION_LIST[3] :
					createPhongShadingExample() ;
					break ;
				case SECTION_LIST[4] :
					createBumpingExample() ;
					break ;
				case SECTION_LIST[5] :
					createReflectionMappingExample() ;
					break ;
				case SECTION_LIST[6] :
					createGalaxyExample() ;
					break ;
			}
		}

		private var flatShadingExample : FlatShadingExample = null ;
		private function createFlatShadingExample() : void
		{
			if( flatShadingExample == null )
				flatShadingExample = new FlatShadingExample() ;
			addChild( flatShadingExample ) ;
		}

		private var gourandExample : GourandExample = null ;
		private function createGourandExample() : void
		{
			if( gourandExample == null )
				gourandExample = new GourandExample() ;
			addChild( gourandExample ) ;
		}

		private var cellShaderExample : CellShaderExample = null ;
		private function createCellShaderExample() : void
		{
			if( cellShaderExample == null )
				cellShaderExample = new CellShaderExample() ;
			addChild( cellShaderExample ) ;
		}

		private var phongShadingExample : PhongShadingExample = null ;
		private function createPhongShadingExample() : void
		{
			if( phongShadingExample == null )
				phongShadingExample = new PhongShadingExample() ;
			addChild( phongShadingExample ) ;
		}

		private var bumpingExample : BumpingExample = null ;
		private function createBumpingExample() : void
		{
			if( bumpingExample == null )
				bumpingExample = new BumpingExample() ;
			addChild( bumpingExample ) ;
		}

		private var reflectionMappingExample : ReflectionMappingExample = null ;
		private function createReflectionMappingExample() : void
		{
			if( reflectionMappingExample == null )
				reflectionMappingExample = new ReflectionMappingExample() ;
			addChild( reflectionMappingExample ) ;
		}

		private var galaxyExample : GalaxyExample = null ;
		private function createGalaxyExample() : void
		{
			if( galaxyExample == null )
				galaxyExample = new GalaxyExample() ;
			addChild( galaxyExample ) ;
		}
	}
}